package com.eqdd.yiqidian.ui.mine.wo;

import android.content.Intent;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;

import com.eqdd.yiqidian.adapter.SectionDividerItemDecoration;
import com.eqdd.yiqidian.base.Config;
import com.eqdd.yiqidian.bean.EnterBean;
import com.eqdd.yiqidian.http.HttpConfig;
import com.eqdd.yiqidian.http.HttpPresneter;
import com.eqdd.yiqidian.ui.MineAuActivity;
import com.eqdd.yiqidian.ui.base.BaseEnterActivity;
import com.eqdd.yiqidian.ui.mine.UserInfoActivity;
import com.eqdd.yiqidian.ui.tongxunlu.FriendDetailInfoActivity;
import com.eqdd.yiqidian.utils.GreenDaoUtil;
import com.eqdd.yiqidian.utils.ToastUtil;
import com.jrmf360.rylib.JrmfClient;

/**
 * Created by lvzhihao on 17-4-17.
 */

public class WoActivity extends BaseEnterActivity {
    private String[] contents = new String[]{
            "个人资料",
            "个人实名认证",
            "钱包",
            "收藏",
            "安全"
    };
    private int[] decoders = new int[]{1, 3};
    private Class[] classes = new Class[]{
            UserInfoActivity.class,
            MineAuActivity.class,
            null,
            CollectionActivity.class,
            SafeActivity.class
    };

    @Override
    public void itemClick(int p) {
        switch (p) {
            case 1:
                startActivityForResult(MineAuActivity.class, null, Config.MINE_AU);
                break;
            case 2:
                JrmfClient.intentWallet(this);
                break;
            default:
                startActivity(classes[p]);
                break;
        }
    }

    @Override
    public void initEnterData() {
        initTopTitleBar(View.VISIBLE, "我");
        int index = 0;
        for (int i = 0; i < contents.length; i++) {
            EnterBean enterBean = new EnterBean();
            if (i == 0) {
                enterBean.setTop(true);
            }
            if (index < decoders.length && i == decoders[index]) {
                index++;
                enterBean.setBottom(true);
                enterBean.setUnderLine(false);
            }
            enterBean.setContent(contents[i]);
            enterBean.setIcon(false);
            enterBean.setEnter(true);
            enterBeans.add(enterBean);
        }
        dataBinding.recyclerView.addItemDecoration(new SectionDividerItemDecoration(this, 2, 2, 1).setHeadHeight(30));
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode) {
            case Config.MINE_AU:
                if (resultCode == Config.SUCCESS) {
                    user = GreenDaoUtil.getUser();
                }
        }
    }
}
